package com.gh.rabbitmq.two;

import com.gh.rabbitmq.utils.RabbitmqUtils;
import com.rabbitmq.client.Channel;

import java.util.Map;
import java.util.Scanner;

/**
 * @Author Eric
 * @Date 2021/7/17 17:15
 * @Version 1.0
 * 生产者 可以发送大量消息
 */
public class Task01 {
    private static final String QUEUE_NAME = "hello";

    public static void main(String[] args) throws Exception{
        Channel channel = RabbitmqUtils.getChannel();
        channel.queueDeclare(QUEUE_NAME,true,false,false,null);
        Scanner scanner=new Scanner(System.in);
        while (scanner.hasNext()){
            String message=scanner.nextLine();
            channel.basicPublish("",QUEUE_NAME,null,message.getBytes());
            System.out.println("发送消息完毕"+message);
        }
    }
}
